from common import cookbook

conn = cookbook.connect()

def update():
    cursor = conn.cursor()
    cursor.execute("UPDATE profile SET cats = cats + 1 WHERE name='Sybil'")
    print("Number of rows updated: %d" % cursor.rowcount)
    cursor.close()

def select():
    cursor = conn.cursor()
    cursor.execute("SELECT id, name, cats FROM profile")
    while True:
        row = cursor.fetchone()
        if row is None:
            break
        print("id: %s, name: %s, cats: %s" %(row[0], row[1], row[2]))
    print("Number of rows returned: %d" % cursor.rowcount)
    cursor.close()

def select2():
    cursor = conn.cursor()
    cursor.execute("SELECT id, name, cats FROM profile")
    for(id, name, cats) in cursor:
        print("id: %s, name: %s, cats: %s" %(id, name, cats))
    print("Number of rows returned: %d" % cursor.rowcount)
    cursor.close()


if __name__=='__main__':
    select2()
    conn.close()